///
///CAN NETWORK CONFIGURATIONS
///
///
#ifndef CANSETTINGS_H
#define CANSETTINGS_H

////singleton
#include <QMainWindow>
#include <QWidget>
#include <QMutex>
#include <QMutexLocker>
#include <QDebug>
#include<QStyleFactory>
#include<QIcon>
#include<QMessageBox>
#include<QMenu>
#include<QContextMenuEvent>
//tree
#include<QStandardItemModel>
#include <QTableView>
#include <QFileDialog>
#include<QPushButton>
#include<QItemDelegate>


//for comboxchannelnumber
#include "newcanselinfopage.h"

namespace Ui {
class CanSettings;
}

class CanSettings : public QMainWindow
{
    Q_OBJECT
public:
    //struct store can mode、 can bitrate 、
    struct CanModeBitrate
    {
        QString canname;//can
        QString cantype;//can type
        QString mode;//mode
        QString bitrate;//bitrate
    };
public:
    //get instance
    static CanSettings *getInstance();
    bool updatetreeview(QString &chanelnum);
    ~CanSettings();
    //tree member
    QStandardItemModel treemodel;
    void onTreeViewMenuRequested(const QPoint &pos);
    void onActionTest();
    void onActionView();
    //set canfilename map
    bool setcanfilemap(QString canname,QString dbfilename);
    //get canfilemap
    QMap<QString,QString> getcanfilemap();

    //get veccanmodebitrate
    QVector<CanModeBitrate> getvecmodbitrate();
    bool setvecmodbitrate(CanModeBitrate &canmbr);


private slots:
    //click tree view
    void on_treeViewCan_clicked(const QModelIndex &index);

    void on_cansettingpushButtonok_clicked();

    void on_cansettingpushButtonCancel_clicked();

private:
    //make unique entity.
     explicit CanSettings(QWidget *parent = nullptr);
    Ui::CanSettings *ui;
     //add instance to point unique entity.
    static CanSettings* instance;
    //for store can and forward db file path or name
    static QMap<QString,QString> canfilemap;
    //store can mode、 can bitrate
    static QVector<CanModeBitrate>   veccanmodebitrate;
};



#endif // CANSETTINGS_H
